package com.example.baselibrary.rx;

import com.example.baselibrary.iview.BaseView;

import io.reactivex.Observer;
import io.reactivex.disposables.Disposable;

/**
 * Rx订阅者默认实现 by zqq on 2018/6/11.
 *      因为需要进行关闭loading，所以把view通过构造方法传进来
 */

public class BaseObserver<T> implements Observer<T> {

    private BaseView baseView;

    public BaseObserver(BaseView baseView) {
        this.baseView = baseView;
    }

    @Override
    public void onSubscribe(Disposable d) {

    }

    @Override
    public void onNext(T t) {

    }

    @Override
    public void onError(Throwable e) {
        baseView.hideLoading();
    }

    @Override
    public void onComplete() {
        baseView.hideLoading();
    }
}
